package com.ctosb.classviewer.clazz.attr;

import com.ctosb.classviewer.ClassReader;
import com.ctosb.classviewer.clazz.cp.CONSTANT_NameAndType_info;
import com.ctosb.classviewer.clazz.cp.CONSTANT_Utf8_info;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class Signature_attribute extends Attribute_info {

    private short signature_index;

    @Override
    protected void doParse(ClassReader classReader) {
        signature_index = classReader.readShort();
    }

    /**
     * 获取签名信息。表示类签名或方法类型签名或字段类型签名
     * @Author alan
     * @Date 2020/12/16 12:10 上午
     * @return
     */
    public String getSignature() {
        return ((CONSTANT_Utf8_info) getClassFile().getConstant_pool()[signature_index]).getValue();
    }
}
